//
//  ScanViewController.m
//  SmartWatch
//
//  Created by zwj on 2022/11/24.
//

#import "ScanViewController.h"
#import "ScanResultView.h"
@interface ScanViewController ()
@end

@implementation ScanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self showResult];
    // 注册观察者
    [SGQRCodeNotificationCenter addObserver:self selector:@selector(SGQRCodeInformationFromeAibum:) name:SGQRCodeInformationFromeAibum object:nil];
    [SGQRCodeNotificationCenter addObserver:self selector:@selector(SGQRCodeInformationFromeScanning:) name:SGQRCodeInformationFromeScanning object:nil];
    
    UIButton *cancel = [UIButton buttonWithType:0];
    cancel.frame = CGRectMake(10, StatusBarHeightConstant, 44, 44);
    cancel.imageView.contentMode = UIViewContentModeScaleAspectFill;
    [cancel setImage:UIImageMake(@"scan_back") forState:UIControlStateNormal];
    cancel.imageEdgeInsets = UIEdgeInsetsMake(8, 8, 8, 8);
    [cancel addTarget:self action:@selector(dismissController) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:cancel];
}

- (void)dismissController {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)SGQRCodeInformationFromeAibum:(NSNotification *)noti {
    // 相册
    [self clearScaning];
}

- (void)SGQRCodeInformationFromeScanning:(NSNotification *)noti {
    NSString *string = noti.object;
    
    [self pauseScaning];
//    [self resumeScaning];
    
    
}

- (void)showResult {
    ScanResultView *resultView = [[ScanResultView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth - 80, 450)];
    self.zh_popupController = [zhPopupController new];
    self.zh_popupController.layoutType = zhPopupLayoutTypeCenter;
    self.zh_popupController.allowPan = NO;
    self.zh_popupController.maskAlpha = 0.7;
    [self.zh_popupController presentContentView:resultView];
}
@end
